package com.klun.concTrueWar.six;

import java.util.Timer;
import java.util.TimerTask;

import static java.util.concurrent.TimeUnit.SECONDS;

/**
 * 错误的 Timer 行为 没看懂timer的用法
 */
public class OutOfTime {

    public static void main(String[] args) throws InterruptedException {
        Timer timer = new Timer();
        timer.schedule(new ThrowTask(),1);
        SECONDS.sleep(1);
        timer.schedule(new ThrowTask(),1);
        SECONDS.sleep(5);

    }

    public static class ThrowTask extends TimerTask {
        @Override
        public void run() {
            System.out.println("A");
        }
    }

}
